-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checked node condition for DaemonSets when updating node. #45649
Conversation
Do we want to requeue on all condition updates? |
I think we should. It shouldn't happen to often. |
|
||
curCond, err := v1helper.GetAvailableNodeConditionType(curNode.Status.Conditions) | ||
if err != nil { | ||
glog.Errorf("Failed to get current node's condition: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is any reason for having this error. The helper should return nil if there is no condition.
f78f79a
to
8c8aa22
Compare
pkg/api/v1/helper/helpers.go
Outdated
@@ -498,3 +498,14 @@ func PersistentVolumeClaimHasClass(claim *v1.PersistentVolumeClaim) bool { | |||
|
|||
return false | |||
} | |||
|
|||
// GetAvailableNodeCondition returns the available NodeCondition of node. | |||
func GetAvailableNodeCondition(conds []v1.NodeCondition) *v1.NodeCondition { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns the first node condition whose status is true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, got that. there'll be multiple condition, e.g. Disk, memory, right?
|
||
nodeConditionTypeEqual := (oldCond == nil && curCond == nil) | ||
if oldCond != nil && curCond != nil { | ||
nodeConditionTypeEqual = (oldCond.Type == curCond.Type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the first node condition is true, all other node condition updates will be ignored.
@k82cn thanks for the fix! Would you add unit tests too? |
sure, will add a unit test for that. |
|
||
if reflect.DeepEqual(oldNode.Labels, curNode.Labels) && | ||
reflect.DeepEqual(oldNode.Spec.Taints, curNode.Spec.Taints) && | ||
v1helper.NodeConditionTypeEqual(oldCond, curCond) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just compare node conditions. No need to filter True
ones before comparing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done; I filter by True with NodeConditionEqual
, if Status
is False
or empty, ignore it.
pkg/api/v1/helper/helpers.go
Outdated
|
||
// NodeConditionTypeEqual returns true if all condition's status & types equals; | ||
// otherwise, returns false. | ||
func NodeConditionTypeEqual(c1 []v1.NodeCondition, c2 []v1.NodeCondition) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename to NodeConditionsEqual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@k8s-bot kops aws e2e test this |
@k8s-bot pull-kubernetes-federation-e2e-gce test this |
pkg/api/v1/helper/helpers.go
Outdated
return true | ||
} | ||
|
||
if len(c1) != 0 || len(c2) != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the goal of this if
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, this's used when filtered status is true
condition before. It should be removed.
@@ -1219,6 +1219,19 @@ func TestUpdateNode(t *testing.T) { | |||
ds: newDaemonSet("ds"), | |||
shouldEnqueue: true, | |||
}, | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests for all use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test when some conditions are false; in this PR, user's case is about out of disk but our logic does not tight to it.
I'll open another PR for resources changed, not solution for that case now.
/assign @lavalamp for approval |
/assign @lavalamp |
@lavalamp , added a helper func |
@k8s-bot pull-kubernetes-federation-e2e-gce test this |
@lavalamp , ping for approve & lgtm :). |
pkg/api/v1/helper/helpers.go
Outdated
@@ -524,3 +524,28 @@ func StorageNodeAffinityToAlphaAnnotation(annotations map[string]string, affinit | |||
annotations[v1.AlphaStorageNodeAffinityAnnotation] = string(json) | |||
return nil | |||
} | |||
|
|||
// NodeConditionEqual returns true if all effective types ("Status" is true) equals; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't what I'd expect an "equal" function to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, I think this's "equal" for the two node condition; if we want an exactly equal, we can use DeepEqual for all fields, including timestamps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lavalamp , is that OK for you? I'd like to get this merged before 1.7 cuts :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@k82cn Not just that, only the ones whose status is true is compared. This is fine because we only care about node condition updates from true to non-true (either false or unknown). I suggest renaming it to NodeInSameContion
, change c1 & c2 to old & cur, and move it to be a private function under daemonset controller code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janetkuo , thanks for the comments, updated :).
1 similar comment
@k8s-bot pull-kubernetes-unit test this |
ping for lgtm label :). |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: janetkuo, k82cn, kargakis, lukaszo The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
@k8s-bot pull-kubernetes-unit test this |
Automatic merge from submit-queue |
/sig apps |
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #45628Release note: